<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Git常用命令（核心） | whoway</title>
    <meta name="description" content="Personal Blog Website">
    <link rel="icon" href="/images/photo.jpg">
  <link rel="manifest" href="/images/photo.jpg">
  <link rel="apple-touch-icon" href="/images/photo.jpg">
  <meta http-quiv="pragma" cotent="no-cache">
  <meta http-quiv="pragma" cotent="no-cache,must-revalidate">
  <meta http-quiv="expires" cotent="0">
    
    <link rel="preload" href="/assets/css/0.styles.0dbae9ec.css" as="style"><link rel="preload" href="/assets/js/app.c70e21ad.js" as="script"><link rel="preload" href="/assets/js/99.54c8207b.js" as="script"><link rel="prefetch" href="/assets/js/10.15222a53.js"><link rel="prefetch" href="/assets/js/100.7e0e5a86.js"><link rel="prefetch" href="/assets/js/101.efd59f25.js"><link rel="prefetch" href="/assets/js/102.dfbdc06c.js"><link rel="prefetch" href="/assets/js/103.d3ab2109.js"><link rel="prefetch" href="/assets/js/104.117957ef.js"><link rel="prefetch" href="/assets/js/105.046e8ff3.js"><link rel="prefetch" href="/assets/js/106.aebdc17d.js"><link rel="prefetch" href="/assets/js/107.248733c2.js"><link rel="prefetch" href="/assets/js/108.a2fecadc.js"><link rel="prefetch" href="/assets/js/109.35196857.js"><link rel="prefetch" href="/assets/js/11.770642f2.js"><link rel="prefetch" href="/assets/js/110.cf3d973c.js"><link rel="prefetch" href="/assets/js/111.f985889a.js"><link rel="prefetch" href="/assets/js/112.ad614f41.js"><link rel="prefetch" href="/assets/js/113.f666653c.js"><link rel="prefetch" href="/assets/js/114.c6c3f384.js"><link rel="prefetch" href="/assets/js/115.e51d3c2f.js"><link rel="prefetch" href="/assets/js/116.4f4b39f5.js"><link rel="prefetch" href="/assets/js/117.99352e11.js"><link rel="prefetch" href="/assets/js/118.c6ae6572.js"><link rel="prefetch" href="/assets/js/119.4ccbe778.js"><link rel="prefetch" href="/assets/js/12.042a92ff.js"><link rel="prefetch" href="/assets/js/120.edda1c4f.js"><link rel="prefetch" href="/assets/js/121.30a638ed.js"><link rel="prefetch" href="/assets/js/122.6efcefb1.js"><link rel="prefetch" href="/assets/js/123.91e6665b.js"><link rel="prefetch" href="/assets/js/124.f27e3d7e.js"><link rel="prefetch" href="/assets/js/125.c75712d5.js"><link rel="prefetch" href="/assets/js/126.ed756cce.js"><link rel="prefetch" href="/assets/js/127.2f06c74c.js"><link rel="prefetch" href="/assets/js/128.d5f6f30e.js"><link rel="prefetch" href="/assets/js/129.508b7eed.js"><link rel="prefetch" href="/assets/js/13.b5280c37.js"><link rel="prefetch" href="/assets/js/130.dc05f9aa.js"><link rel="prefetch" href="/assets/js/131.e0ba69b1.js"><link rel="prefetch" href="/assets/js/132.d79bcaa4.js"><link rel="prefetch" href="/assets/js/133.34acc01a.js"><link rel="prefetch" href="/assets/js/134.dabf64d5.js"><link rel="prefetch" href="/assets/js/135.ad90c915.js"><link rel="prefetch" href="/assets/js/136.dbb0074f.js"><link rel="prefetch" href="/assets/js/137.284ad365.js"><link rel="prefetch" href="/assets/js/138.a4b6856f.js"><link rel="prefetch" href="/assets/js/139.c9c1e20f.js"><link rel="prefetch" href="/assets/js/14.df02ba38.js"><link rel="prefetch" href="/assets/js/140.8b0a9269.js"><link rel="prefetch" href="/assets/js/141.9c7759c5.js"><link rel="prefetch" href="/assets/js/142.a4201a82.js"><link rel="prefetch" href="/assets/js/143.d7da6e8c.js"><link rel="prefetch" href="/assets/js/144.5e48e65d.js"><link rel="prefetch" href="/assets/js/145.a0e2633c.js"><link rel="prefetch" href="/assets/js/146.3c775f9b.js"><link rel="prefetch" href="/assets/js/147.22add89a.js"><link rel="prefetch" href="/assets/js/148.cfde1009.js"><link rel="prefetch" href="/assets/js/149.ffc835b5.js"><link rel="prefetch" href="/assets/js/15.fbdfc4ee.js"><link rel="prefetch" href="/assets/js/150.406c4b20.js"><link rel="prefetch" href="/assets/js/151.b2040eea.js"><link rel="prefetch" href="/assets/js/152.7bc65661.js"><link rel="prefetch" href="/assets/js/153.1d7c65e3.js"><link rel="prefetch" href="/assets/js/154.1309de49.js"><link rel="prefetch" href="/assets/js/155.81d3ee1f.js"><link rel="prefetch" href="/assets/js/156.154a4ef2.js"><link rel="prefetch" href="/assets/js/16.e5eb6147.js"><link rel="prefetch" href="/assets/js/17.57853c4a.js"><link rel="prefetch" href="/assets/js/18.cb9d7518.js"><link rel="prefetch" href="/assets/js/19.f354dc47.js"><link rel="prefetch" href="/assets/js/2.570d8a23.js"><link rel="prefetch" href="/assets/js/20.b5af7fad.js"><link rel="prefetch" href="/assets/js/21.0b1928fe.js"><link rel="prefetch" href="/assets/js/22.f78666de.js"><link rel="prefetch" href="/assets/js/23.29c3f366.js"><link rel="prefetch" href="/assets/js/24.6f596516.js"><link rel="prefetch" href="/assets/js/25.14067b60.js"><link rel="prefetch" href="/assets/js/26.74ba4989.js"><link rel="prefetch" href="/assets/js/27.13d60edd.js"><link rel="prefetch" href="/assets/js/28.9523cb32.js"><link rel="prefetch" href="/assets/js/29.8ec842e9.js"><link rel="prefetch" href="/assets/js/3.3fb3d2e0.js"><link rel="prefetch" href="/assets/js/30.805597a8.js"><link rel="prefetch" href="/assets/js/31.831b195d.js"><link rel="prefetch" href="/assets/js/32.063c672d.js"><link rel="prefetch" href="/assets/js/33.6d93fac3.js"><link rel="prefetch" href="/assets/js/34.56e8263c.js"><link rel="prefetch" href="/assets/js/35.dbe688bb.js"><link rel="prefetch" href="/assets/js/36.dc5af2c1.js"><link rel="prefetch" href="/assets/js/37.0a7494f6.js"><link rel="prefetch" href="/assets/js/38.fe4fc171.js"><link rel="prefetch" href="/assets/js/39.f5ed5e92.js"><link rel="prefetch" href="/assets/js/4.2c405ec8.js"><link rel="prefetch" href="/assets/js/40.fe7e2714.js"><link rel="prefetch" href="/assets/js/41.30b0811d.js"><link rel="prefetch" href="/assets/js/42.76f52d62.js"><link rel="prefetch" href="/assets/js/43.e7bb0817.js"><link rel="prefetch" href="/assets/js/44.ead0e883.js"><link rel="prefetch" href="/assets/js/45.235df046.js"><link rel="prefetch" href="/assets/js/46.5f09e829.js"><link rel="prefetch" href="/assets/js/47.67116354.js"><link rel="prefetch" href="/assets/js/48.31f34543.js"><link rel="prefetch" href="/assets/js/49.10b5ebba.js"><link rel="prefetch" href="/assets/js/5.6f47322c.js"><link rel="prefetch" href="/assets/js/50.c0f0b7f1.js"><link rel="prefetch" href="/assets/js/51.5143f3bf.js"><link rel="prefetch" href="/assets/js/52.eeddfd48.js"><link rel="prefetch" href="/assets/js/53.eb790db5.js"><link rel="prefetch" href="/assets/js/54.8fe5421c.js"><link rel="prefetch" href="/assets/js/55.d8f9004b.js"><link rel="prefetch" href="/assets/js/56.62ac9b92.js"><link rel="prefetch" href="/assets/js/57.a9caec0d.js"><link rel="prefetch" href="/assets/js/58.f93fc522.js"><link rel="prefetch" href="/assets/js/59.a81a03aa.js"><link rel="prefetch" href="/assets/js/6.8c2ea393.js"><link rel="prefetch" href="/assets/js/60.ab782775.js"><link rel="prefetch" href="/assets/js/61.6dd12daf.js"><link rel="prefetch" href="/assets/js/62.76f4b01f.js"><link rel="prefetch" href="/assets/js/63.6f8a4742.js"><link rel="prefetch" href="/assets/js/64.6f8bb1fa.js"><link rel="prefetch" href="/assets/js/65.4120a44b.js"><link rel="prefetch" href="/assets/js/66.360c2d2b.js"><link rel="prefetch" href="/assets/js/67.26f84d32.js"><link rel="prefetch" href="/assets/js/68.68f45e5e.js"><link rel="prefetch" href="/assets/js/69.e311eb56.js"><link rel="prefetch" href="/assets/js/7.6762b2d7.js"><link rel="prefetch" href="/assets/js/70.cea82674.js"><link rel="prefetch" href="/assets/js/71.783ddcf7.js"><link rel="prefetch" href="/assets/js/72.e5467385.js"><link rel="prefetch" href="/assets/js/73.b8fb681b.js"><link rel="prefetch" href="/assets/js/74.1bae37db.js"><link rel="prefetch" href="/assets/js/75.024387e5.js"><link rel="prefetch" href="/assets/js/76.a8e53010.js"><link rel="prefetch" href="/assets/js/77.8c55500a.js"><link rel="prefetch" href="/assets/js/78.7ce90bf5.js"><link rel="prefetch" href="/assets/js/79.ef71713f.js"><link rel="prefetch" href="/assets/js/8.788a6364.js"><link rel="prefetch" href="/assets/js/80.acad589d.js"><link rel="prefetch" href="/assets/js/81.02670d10.js"><link rel="prefetch" href="/assets/js/82.53b7b1ac.js"><link rel="prefetch" href="/assets/js/83.99eb8581.js"><link rel="prefetch" href="/assets/js/84.d1535ce3.js"><link rel="prefetch" href="/assets/js/85.fe2b7de9.js"><link rel="prefetch" href="/assets/js/86.41850272.js"><link rel="prefetch" href="/assets/js/87.1cdc6df9.js"><link rel="prefetch" href="/assets/js/88.01bf3461.js"><link rel="prefetch" href="/assets/js/89.17c69819.js"><link rel="prefetch" href="/assets/js/9.3813842d.js"><link rel="prefetch" href="/assets/js/90.f6ae7e35.js"><link rel="prefetch" href="/assets/js/91.507bc284.js"><link rel="prefetch" href="/assets/js/92.90551782.js"><link rel="prefetch" href="/assets/js/93.dc442d78.js"><link rel="prefetch" href="/assets/js/94.315f4e94.js"><link rel="prefetch" href="/assets/js/95.ccd6c6bf.js"><link rel="prefetch" href="/assets/js/96.0c6d89d0.js"><link rel="prefetch" href="/assets/js/97.1a9f10a9.js"><link rel="prefetch" href="/assets/js/98.43be3caa.js">
    <link rel="stylesheet" href="/assets/css/0.styles.0dbae9ec.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">whoway</span></a> <div class="links" style="max-width:nullpx;"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🎓Coding</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/00.Coding/TheBeautyOfProgramming/" class="nav-link">🔖编程之美题解</a></li><li class="dropdown-item"><!----> <a href="/00.Coding/CodeWarehouse/" class="nav-link">🔖代码意识流</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🚀语言</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/01.Language/Overview/" class="nav-link">🔖概述</a></li><li class="dropdown-item"><!----> <a href="/01.Language/C/" class="nav-link">⭐️C</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Cpp/" class="nav-link">🚀C++</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Java/" class="nav-link">☕️Java</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Python/" class="nav-link">🧩Python3</a></li></ul></div></div><div class="nav-item"><a href="/02.Hardware/" class="nav-link">✔️硬件基础</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⭐️软件基础</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/03.Software/01.DataStructureAndAlgorithm/" class="nav-link">🐾数据结构和算法</a></li><li class="dropdown-item"><!----> <a href="/03.Software/02.OS/" class="nav-link">💻操作系统</a></li><li class="dropdown-item"><!----> <a href="/03.Software/03.Net/" class="nav-link">☁️计算机网络</a></li><li class="dropdown-item"><!----> <a href="/03.Software/04.SE/" class="nav-link">✅软件工程</a></li></ul></div></div><div class="nav-item"><a href="/04.Database/" class="nav-link">🎨数据库</a></div><div class="nav-item"><a href="/05.Engineer/" class="nav-link router-link-active">🔖学术/工程</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⚙️工具</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/06.Tools/01.employment/" class="nav-link">🔖求职</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/02.efficiency/" class="nav-link">🚀效能</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/03.windows/" class="nav-link">⚙️Windows</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/04.design/" class="nav-link">🧩设计</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/05.linux/" class="nav-link">🐉Linux</a></li></ul></div></div><div class="nav-item"><a href="https://github.com/whoway" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav></div></header> <div class="sidebar-mask"></div> <div class="sidebar"><nav class="nav-links"><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🎓Coding</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/00.Coding/TheBeautyOfProgramming/" class="nav-link">🔖编程之美题解</a></li><li class="dropdown-item"><!----> <a href="/00.Coding/CodeWarehouse/" class="nav-link">🔖代码意识流</a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">🚀语言</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/01.Language/Overview/" class="nav-link">🔖概述</a></li><li class="dropdown-item"><!----> <a href="/01.Language/C/" class="nav-link">⭐️C</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Cpp/" class="nav-link">🚀C++</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Java/" class="nav-link">☕️Java</a></li><li class="dropdown-item"><!----> <a href="/01.Language/Python/" class="nav-link">🧩Python3</a></li></ul></div></div><div class="nav-item"><a href="/02.Hardware/" class="nav-link">✔️硬件基础</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⭐️软件基础</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/03.Software/01.DataStructureAndAlgorithm/" class="nav-link">🐾数据结构和算法</a></li><li class="dropdown-item"><!----> <a href="/03.Software/02.OS/" class="nav-link">💻操作系统</a></li><li class="dropdown-item"><!----> <a href="/03.Software/03.Net/" class="nav-link">☁️计算机网络</a></li><li class="dropdown-item"><!----> <a href="/03.Software/04.SE/" class="nav-link">✅软件工程</a></li></ul></div></div><div class="nav-item"><a href="/04.Database/" class="nav-link">🎨数据库</a></div><div class="nav-item"><a href="/05.Engineer/" class="nav-link router-link-active">🔖学术/工程</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title">⚙️工具</span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/06.Tools/01.employment/" class="nav-link">🔖求职</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/02.efficiency/" class="nav-link">🚀效能</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/03.windows/" class="nav-link">⚙️Windows</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/04.design/" class="nav-link">🧩设计</a></li><li class="dropdown-item"><!----> <a href="/06.Tools/05.linux/" class="nav-link">🐉Linux</a></li></ul></div></div><div class="nav-item"><a href="https://github.com/whoway" target="_blank" rel="noopener noreferrer" class="nav-link external">
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></div> <!----></nav>  <ul class="sidebar-links"><li><div class="sidebar-group first"><p class="sidebar-heading open"><span>Git常用命令（核心）</span> <!----></p> <ul class="sidebar-group-items"><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#📑目录" class="sidebar-link">📑目录</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_1-git安装" class="sidebar-link">1.Git安装</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-”首次“使用git设置⭐️" class="sidebar-link">2.”首次“使用Git设置⭐️</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-1-本地的git的bash中建立『非对称加密秘钥』" class="sidebar-link">2.1.本地的Git的bash中建立『非对称加密秘钥』</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-2-gitee和github绑定邮箱" class="sidebar-link">2.2.Gitee和GitHub绑定邮箱</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-3-git在本地绑定邮箱和远程的gitee和github的用户名" class="sidebar-link">2.3.Git在本地绑定邮箱和远程的Gitee和Github的用户名</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-4-首次提交到仓库记得加-u参数" class="sidebar-link">2.4.首次提交到仓库记得加-u参数</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-5-git的其他知识" class="sidebar-link">2.5.git的其他知识</a></li></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-常用场景-重要" class="sidebar-link">3.常用场景(重要)</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-1-git同时关联github和gitee" class="sidebar-link">3.1.Git同时关联github和gitee</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-2-查看本地分支和哪个远程分支绑定" class="sidebar-link">3.2.查看本地分支和哪个远程分支绑定</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-3-git『取消关联某仓库』，去关联其他仓库" class="sidebar-link">3.3.Git『取消关联某仓库』，去关联其他仓库</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-4-git-diff查看工作区和版本库里面最新版本的区别⭐️" class="sidebar-link">3.4.git diff查看工作区和版本库里面最新版本的区别⭐️</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-5-本地文件丢失了-有人提交了更新『需远程拉下来，进行提交』⭐️" class="sidebar-link">3.5.本地文件丢失了/有人提交了更新『需远程拉下来，进行提交』⭐️</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-6-git查看某个文件的修改历史⭐️公司参考前辈的写法" class="sidebar-link">3.6.git查看某个文件的修改历史⭐️公司参考前辈的写法</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-7-解决git-pull的冲突" class="sidebar-link">3.7.解决git pull的冲突</a></li></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-git分支管理（难点）⭐️" class="sidebar-link">4.Git分支管理（难点）⭐️</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-1-『新建分支』并且上传github，让他自动生成分支" class="sidebar-link">4.1.『新建分支』并且上传github，让他自动生成分支</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#『注意⭐️分支之后，记得要及时git-pull』" class="sidebar-link">『注意⭐️分支之后，记得要及时git pull』</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-2-如何删除远程某分支？" class="sidebar-link">4.2.如何删除远程某分支？</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-3-git中可以使用的linux命令『探秘』" class="sidebar-link">4.3.Git中可以使用的linux命令『探秘』</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-4-分支提交失败的情况" class="sidebar-link">4.4.分支提交失败的情况</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-5-git-add和git-commit的对比" class="sidebar-link">4.5.git add和git commit的对比</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-6-版本回退—回到过去" class="sidebar-link">4.6.版本回退—回到过去</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-7-神奇的git-reset" class="sidebar-link">4.7.神奇的git reset</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-8-git-checkout" class="sidebar-link">4.8.git checkout --</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-9-git-从远程服务器更新本地项目" class="sidebar-link">4.9.git 从远程服务器更新本地项目</a></li></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_5-github强化" class="sidebar-link">5.GitHub强化</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_5-1-github搜索强化" class="sidebar-link">5.1.GitHub搜索强化</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_5-2-忽略管理的一个“坑”" class="sidebar-link">5.2.忽略管理的一个“坑”</a></li></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#⭐️工程实践总结" class="sidebar-link">⭐️工程实践总结</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_1-写完代码要提交-提交pr" class="sidebar-link">1.写完代码要提交+提交PR</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_2-提交的分支错误-删除本地分支和远程分支" class="sidebar-link">2.提交的分支错误-删除本地分支和远程分支</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_3-代码走查「自行比较自己的分支」" class="sidebar-link">3.代码走查「自行比较自己的分支」</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_4-git撤销对某个文件的修改" class="sidebar-link">4.git撤销对某个文件的修改</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_5-公司给了新的分支-拉去" class="sidebar-link">5.公司给了新的分支-拉去</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_6-如何用git命令生成patch和打patch" class="sidebar-link">6.如何用git命令生成Patch和打Patch</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_7-git-cherry-pick进行commit的pick" class="sidebar-link">7.git cherry-pick进行commit的pick</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_8-从commit到stage到修改到取消修改-回退-git-reset-xx-soft" class="sidebar-link">8.从commit到stage到修改到取消修改(回退)git --reset XX --soft</a></li><li class="sidebar-sub-header"><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#_9-如果公司外网域名宕掉-git远程仓库地址变更本地如何修改" class="sidebar-link">9.如果公司外网域名宕掉-git远程仓库地址变更本地如何修改</a></li></ul></li><li><a href="/05.Engineer/E5.Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4.html#🍀参考资料" class="sidebar-link">🍀参考资料</a><ul class="sidebar-sub-headers"></ul></li></ul></div></li></ul> </div> <div class="page"> <div class="content"><h1 id="git常用命令（核心）"><a href="#git常用命令（核心）" class="header-anchor">#</a> Git常用命令（核心）</h1> <div class="language-txt line-numbers-mode"><pre class="language-text"><code>&lt;font style=&quot;background:yellow&quot;&gt;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h2 id="📑目录"><a href="#📑目录" class="header-anchor">#</a> 📑目录</h2> <p>[TOC]</p> <h2 id="_1-git安装"><a href="#_1-git安装" class="header-anchor">#</a> 1.Git安装</h2> <ul><li>Windows上安装Git，Git官网直接下载安装程序</li> <li>然后按<strong>默认</strong>选项安装即可（一路的按下一步！😄）</li></ul> <h2 id="_2-”首次“使用git设置⭐️"><a href="#_2-”首次“使用git设置⭐️" class="header-anchor">#</a> 2.”首次“使用Git设置⭐️</h2> <h3 id="_2-1-本地的git的bash中建立『非对称加密秘钥』"><a href="#_2-1-本地的git的bash中建立『非对称加密秘钥』" class="header-anchor">#</a> 2.1.本地的Git的bash中建立『<code>非对称加密秘钥</code>』</h3> <ul><li>1.本地Git bash随便在哪个目录输入下面命令（注意，邮箱要和你<code>Gitee</code>和<code>GitHub</code>或<code>GitLab</code>上的一致）</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>ssh-keygen -t rsa -C <span class="token string">&quot;flushbit@163.com&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li><p>然后<strong>不论这行命令后问你什么，你一路enter</strong>，就能生成秘钥</p></li> <li><p>2.查找秘钥中的<strong>公钥</strong>：借助<code>everthing</code>软件查找<code>.ssh</code></p> <ul><li>其实，这个公钥叫作<code>id_rsa.pub</code>，重点在<code>.pub</code>浅显易懂，而另一个是私钥，是本地用</li> <li>如果熟悉window目录结构的，可以直接去“<code>系统盘</code>”目录下的<code>users</code>中找<code>.ssh</code>文件，在那个里面</li></ul></li> <li><p>3.将该公钥放在<code>Gitee</code>和<code>GitHub</code>，这样，你上传代码到仓库就能有安全性能保证，有的还能保证，这样才能上传到仓库，不然不准</p></li></ul> <h3 id="_2-2-gitee和github绑定邮箱"><a href="#_2-2-gitee和github绑定邮箱" class="header-anchor">#</a> 2.2.<code>Gitee</code>和<code>GitHub</code>绑定邮箱</h3> <ul><li>自行绑定邮箱，因为这样，才能用这个邮箱，识别哪个Git上传的，贡献度，他们会计算</li></ul> <h3 id="_2-3-git在本地绑定邮箱和远程的gitee和github的用户名"><a href="#_2-3-git在本地绑定邮箱和远程的gitee和github的用户名" class="header-anchor">#</a> 2.3.Git在本地绑定<code>邮箱</code>和远程的Gitee和Github的用户名</h3> <blockquote><p><strong>设置本机器的全局git用户名和邮箱</strong></p></blockquote> <p>安装完成后，还需要最后一步设置，在命令行输入：</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git config<span class="token parameter"> --global</span> user.name </span><span class="token string">&quot;你的用户名&quot;</span>
<span class="token command">$ git config<span class="token parameter"> --global</span> user.email </span><span class="token string">&quot;你的邮箱-格式如后email@example.com&quot;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li><p>因为Git是分布式版本控制系统，所以，每个机器都必须自报家门：你的名字和Email地址。</p></li> <li><p>注意<code>git config</code>命令的<code>--global</code>参数，用了这个参数</p></li> <li><p>表示你这台机器上<strong>所有的Git仓库</strong>都会使用这个配置，当然也可以对<strong>某个仓库</strong>指定不同的用户名和Email地址。</p></li> <li><p>设置后，如果你想，查看git全局用户名和邮箱</p></li></ul> <p>重点：</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code>git config user.name
git config user.email
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>例子</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code>C:\Users\MaxWell&gt;git config user.name
HACV
C:\Users\MaxWell&gt;git config user.email
43233568+FOXF1-0@users.noreply.github.com
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="_2-4-首次提交到仓库记得加-u参数"><a href="#_2-4-首次提交到仓库记得加-u参数" class="header-anchor">#</a> 2.4.首次提交到仓库记得加-u参数</h3> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git push<span class="token parameter"> -u</span> origin master</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>由于远程库是空的，我们第一次推送master分支时，加上了<code>-u</code>参数，Git不但会把本地的master分支内容推送的远程新的master分支，还会把本地的master分支和远程的master分支关联起来，在以后的推送或者拉取时就可以简化命令。</li></ul> <h3 id="_2-5-git的其他知识"><a href="#_2-5-git的其他知识" class="header-anchor">#</a> 2.5.git的其他知识</h3> <ul><li>注意：<code>git clone</code>下来的文件，顺路会把<code>.git</code>也下载下来，所以，我们才能提交</li></ul> <h2 id="_3-常用场景-重要"><a href="#_3-常用场景-重要" class="header-anchor">#</a> 3.常用场景(重要)</h2> <h3 id="_3-1-git同时关联github和gitee"><a href="#_3-1-git同时关联github和gitee" class="header-anchor">#</a> 3.1.Git同时关联github和gitee</h3> <ul><li><p>1.创建新版本库，进行开源</p></li> <li><p>2.初始化一个Git的版本控制咯</p></li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code>git init
touch README.md
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li>3.提交到本地分支上</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>git add README.md
git commit -m &quot;first commit:smile:&quot;
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li>4.<strong>绑定远程版本库（本场景的核心解决方案）</strong></li></ul> <p>重要可以修改的地方，同时用来更新github和gitee</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code>git remote add origin git@gitee.com:HACV/dos.git
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li><strong>注意，可以不叫origin那样的名字</strong>。比如，我们为了同时绑定GitHub和Gitee，我们使用下面的</li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code>git remote add mygitee git@gitee.com:HACV/dos.git
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><ul><li>只有第一次提交才需要加上-u</li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code>git push -u origin master
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_3-2-查看本地分支和哪个远程分支绑定"><a href="#_3-2-查看本地分支和哪个远程分支绑定" class="header-anchor">#</a> 3.2.查看本地分支和哪个远程分支绑定</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>//命令1
MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/Windows <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ <span class="token function">git</span> remote -v
mygitee git@gitee.com:HACV/dos.git <span class="token punctuation">(</span>fetch<span class="token punctuation">)</span>
mygitee git@gitee.com:HACV/dos.git <span class="token punctuation">(</span>push<span class="token punctuation">)</span>


//命令2
MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/Windows <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ <span class="token function">git</span> push -u mygitee master
The authenticity of <span class="token function">host</span> <span class="token string">'gitee.com (212.64.62.183)'</span> can<span class="token string">'t be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? y
Please type '</span><span class="token function">yes</span><span class="token string">' or '</span>no<span class="token string">': y
Please type '</span><span class="token function">yes</span><span class="token string">' or '</span>no<span class="token string">': y
Please type '</span><span class="token function">yes</span><span class="token string">' or '</span>no<span class="token string">': yes
Warning: Permanently added '</span>gitee.com,212.64.62.183<span class="token string">' (ECDSA) to the list of known hosts.
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 313 bytes | 313.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Powered by GITEE.COM [GNK-5.0]
To gitee.com:HACV/dos.git
 * [new branch]      master -&gt; master
Branch '</span>master<span class="token string">' set up to track remote branch '</span>master<span class="token string">' from '</span>mygitee'.


//命令3
MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/Windows <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br></div></div><h3 id="_3-3-git『取消关联某仓库』，去关联其他仓库"><a href="#_3-3-git『取消关联某仓库』，去关联其他仓库" class="header-anchor">#</a> 3.3.Git『取消关联某仓库』，去关联其他仓库</h3> <ul><li>命令<code>rm</code>，一看就和linux下的命令差不多</li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code>//取消关联某仓库
MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/DOS/_book (master)
<span class="token command">$ git remote rm mygitee</span>


MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/DOS/_book (master)
<span class="token command">$ git remote<span class="token parameter"> -v</span></span>


//添加新的关联某仓库=================new=========================
MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/DOS/_book (master)
<span class="token command">$ git remote add mygitee git@gitee.com:HACV/demo.git</span>


MaxWell@DESKTOP-5B8E7K2 MINGW64 /d/___MyGitbook/DOS/_book (master)
<span class="token command">$ git push<span class="token parameter"> -u</span> mygitee master</span>
Counting objects: 150, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (140/140), done.
Writing objects: 100% (150/150), 3.68 MiB | 3.56 MiB/s, done.
Total 150 (delta 29), reused 0 (delta 0)
remote: Resolving deltas: 100% (29/29), done.
remote: Powered by GITEE.COM [GNK-5.0]
To gitee.com:HACV/demo.git
 * [new branch]      master -&gt; master
Branch <span class="token string">'master'</span> set up to track remote branch <span class="token string">'master'</span> from <span class="token string">'mygitee'</span>.
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br></div></div><h3 id="_3-4-git-diff查看工作区和版本库里面最新版本的区别⭐️"><a href="#_3-4-git-diff查看工作区和版本库里面最新版本的区别⭐️" class="header-anchor">#</a> 3.4.<code>git diff</code>查看工作区和版本库里面最新版本的区别⭐️</h3> <ul><li>比如想看<code>README.md</code>的区别</li> <li>用<code>git diff HEAD -- README.md</code>命令可以查看工作区和版本库里面最新版本的区别</li></ul> <div class="language-c line-numbers-mode"><pre class="language-c"><code>MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">ttt</span> <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ git diff HEAD <span class="token operator">--</span> README<span class="token punctuation">.</span>md
diff <span class="token operator">--</span>git a<span class="token operator">/</span>README<span class="token punctuation">.</span>md b<span class="token operator">/</span>README<span class="token punctuation">.</span>md
index <span class="token number">088</span>d087<span class="token punctuation">.</span><span class="token number">.72</span>b8ba5 <span class="token number">100644</span>
<span class="token operator">--</span><span class="token operator">-</span> a<span class="token operator">/</span>README<span class="token punctuation">.</span>md
<span class="token operator">++</span><span class="token operator">+</span> b<span class="token operator">/</span>README<span class="token punctuation">.</span>md
@@ <span class="token operator">-</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">10</span> <span class="token operator">+</span><span class="token number">30</span><span class="token punctuation">,</span><span class="token number">3</span> @@ Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台（同时支持 SVN


<span class="token operator">-</span><span class="token number">3.</span>  你可以 <span class="token punctuation">[</span>https<span class="token operator">:</span><span class="token comment">//gitee.com/explore](https://gitee.com/explore) 这个地址来了</span>
解 Gitee 上的优秀开源项目
<span class="token operator">-</span><span class="token number">4.</span>  <span class="token punctuation">[</span>GVP<span class="token punctuation">]</span><span class="token punctuation">(</span>https<span class="token operator">:</span><span class="token comment">//gitee.com/gvp) 全称是 Gitee 最有价值开源项目，是综合评定出的</span>
优秀开源项目
<span class="token operator">-</span><span class="token number">5.</span>  Gitee 官方提供的使用手册 <span class="token punctuation">[</span>https<span class="token operator">:</span><span class="token comment">//gitee.com/help](https://gitee.com/help)</span>
<span class="token operator">-</span><span class="token number">6.</span>  Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 <span class="token punctuation">[</span>https<span class="token operator">:</span><span class="token comment">//gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><h3 id="_3-5-本地文件丢失了-有人提交了更新『需远程拉下来，进行提交』⭐️"><a href="#_3-5-本地文件丢失了-有人提交了更新『需远程拉下来，进行提交』⭐️" class="header-anchor">#</a> 3.5.本地文件丢失了/有人提交了更新『需远程拉下来，进行提交』⭐️</h3> <blockquote><p>git fetch &amp; pull详解</p></blockquote> <ul><li><code>git fetch</code>是将远程主机的最新内容<strong>拉到本地</strong>，用户在检查了以后<strong>决定</strong>是否合并到工作本机分支中。</li> <li>而<code>git pull</code> 则是将远程主机的最新内容拉下来后直接合并
<ul><li>即：<code>git pull = git fetch + git merge</code>，这样<strong>可能会产生冲突</strong>，需要手动解决。</li></ul></li></ul> <h3 id="_3-6-git查看某个文件的修改历史⭐️公司参考前辈的写法"><a href="#_3-6-git查看某个文件的修改历史⭐️公司参考前辈的写法" class="header-anchor">#</a> 3.6.<code>git</code>查看某个文件的修改历史⭐️公司参考前辈的写法</h3> <p>我看到的更好的方法。</p> <ul><li>1.<code>git log filename</code></li></ul> <p>可以看到fileName相关的commit记录</p> <ul><li>2.<code>git log -p filenam</code></li></ul> <p>可以显示每次提交的diff</p> <ul><li>3.只看某次提交中的某个文件变化，可以直接加上fileName</li></ul> <h3 id="_3-7-解决git-pull的冲突"><a href="#_3-7-解决git-pull的冲突" class="header-anchor">#</a> 3.7.解决<code>git pull</code>的冲突</h3> <ul><li>git pull更新<code>hcc_riscv_gcc</code>以获得更</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>warning: redirecting to http://xxxxxxxxxxxxxxvip:仓库名
Updating 69f2ed6 
error: Your <span class="token builtin class-name">local</span> changes to the following files would be overwritten by merge:
        opeource/aute.cache/requests
Please commit your changes or stash them before you merge.
Aborting
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><ul><li>出现这个问题的原因是其他人修改了xxx.php并提交到版本库中去了，而你本地也修改了xxx.php，这时候你进行git pull操作就好出现冲突了，解决方法，在上面的提示中也说的很明确了。</li> <li>参照<a href="https://blog.csdn.net/oguro/article/details/103051511" target="_blank" rel="noopener noreferrer">解决方案<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul> <h4 id="_3-7-1-保留本地的修改-的改法"><a href="#_3-7-1-保留本地的修改-的改法" class="header-anchor">#</a> 3.7.1.保留本地的修改 的改法</h4> <ul><li>1）<strong>直接commit本地的修改 ----一般不用这种方法</strong></li> <li>2）通过git stash  ---- 通常用这种方法（==我用了这个方案解决==）</li> <li>通过git stash将工作区恢复到上次提交的内容，同时备份本地所做的修改，之后就可以正常git pull了，git pull完成后，执行git stash pop将之前本地做的修改应用到当前工作区。</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> stash

<span class="token function">git</span> pull

<span class="token function">git</span> stash pop
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>git stash: 备份当前的工作区的内容，从最近的一次提交中读取相关内容，让工作区保证和上次提交的内容一致。同时，将当前的工作区内容保存到Git栈中。</li> <li>git stash pop: 从Git栈中读取最近一次保存的内容，恢复工作区的相关内容。由于可能存在多个Stash的内容，所以用栈来管理，pop会从最近的一个stash中读取内容并恢复。</li> <li>git stash list: 显示Git栈内的所有备份，可以利用这个列表来决定从那个地方恢复。</li> <li>git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现，原来stash的哪些节点都消失了</li></ul> <h4 id="_3-7-2-放弃本地修改-的改法-—这种方法会丢弃本地修改的代码，而且不可找回"><a href="#_3-7-2-放弃本地修改-的改法-—这种方法会丢弃本地修改的代码，而且不可找回" class="header-anchor">#</a> 3.7.2.放弃本地修改 的改法 —这种方法会丢弃本地修改的代码，而且不可找回</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> reset --hard

<span class="token function">git</span> pull
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><h2 id="_4-git分支管理（难点）⭐️"><a href="#_4-git分支管理（难点）⭐️" class="header-anchor">#</a> 4.Git分支管理（难点）⭐️</h2> <h3 id="_4-1-『新建分支』并且上传github，让他自动生成分支"><a href="#_4-1-『新建分支』并且上传github，让他自动生成分支" class="header-anchor">#</a> 4.1.『新建分支』并且上传github，让他自动生成分支</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>新建分支并跳转到分支
<span class="token function">git</span> checkout -b 分支名

比如下面的
<span class="token function">git</span> checkout -b English
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>git checkout</li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token deleted">---------------------唯一成功的————————————————</span>
MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (master)
<span class="token command">$ git checkout<span class="token parameter"> -b</span> English</span>
Switched to a new branch <span class="token string">'English'</span>

MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (English)
$ ll
total 4
drwxr-xr-x 1 MaxWell 197121  0 5月   2 08:53 China/
<span class="token deleted">-rw-r--r-- 1 MaxWell 197121 30 5月   2 08:53 README.md</span>

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><p>但是好像删的话就比较麻烦了。</p> <ul><li><code>git log --graph</code>命令可以看到分支合并图。</li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code>合并分支时，加上--no-ff参数就可以用普通模式合并，合并后的历史有分支，能看出来曾经做过合并，而fast forward合并就看不出来曾经做过合并。
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="『注意⭐️分支之后，记得要及时git-pull』"><a href="#『注意⭐️分支之后，记得要及时git-pull』" class="header-anchor">#</a> 『注意⭐️分支之后，记得要及时<code>git pull</code>』</h3> <ul><li>不然，2个分支都一样。</li></ul> <div class="language-cpp line-numbers-mode"><pre class="language-cpp"><code>MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>English<span class="token punctuation">)</span>
$ git add <span class="token punctuation">.</span>

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>English<span class="token punctuation">)</span>
$ git commit <span class="token operator">-</span>m <span class="token string">&quot;提交分支&quot;</span>
<span class="token punctuation">[</span>English cf8ac23<span class="token punctuation">]</span> 提交分支
 <span class="token number">2</span> files changed<span class="token punctuation">,</span> <span class="token number">2</span> <span class="token function">insertions</span><span class="token punctuation">(</span><span class="token operator">+</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">53</span> <span class="token function">deletions</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token punctuation">)</span>
 <span class="token keyword">delete</span> mode <span class="token number">100644</span> <span class="token string">&quot;China/\346\240\274\345\274\217\350\246\201\346\261\202.md&quot;</span>

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>English<span class="token punctuation">)</span>
$ git push origin English
Counting objects<span class="token operator">:</span> <span class="token number">3</span><span class="token punctuation">,</span> done<span class="token punctuation">.</span>
Delta compression <span class="token keyword">using</span> up to <span class="token number">4</span> threads<span class="token punctuation">.</span>
Compressing objects<span class="token operator">:</span> <span class="token number">100</span><span class="token operator">%</span> <span class="token punctuation">(</span><span class="token number">2</span><span class="token operator">/</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> done<span class="token punctuation">.</span>
Writing objects<span class="token operator">:</span> <span class="token number">100</span><span class="token operator">%</span> <span class="token punctuation">(</span><span class="token number">3</span><span class="token operator">/</span><span class="token number">3</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token number">271</span> bytes <span class="token operator">|</span> <span class="token number">271.00</span> KiB<span class="token operator">/</span>s<span class="token punctuation">,</span> done<span class="token punctuation">.</span>
Total <span class="token number">3</span> <span class="token punctuation">(</span>delta <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">,</span> reused <span class="token number">0</span> <span class="token punctuation">(</span>delta <span class="token number">0</span><span class="token punctuation">)</span>
remote<span class="token operator">:</span> Powered by GITEE<span class="token punctuation">.</span>COM <span class="token punctuation">[</span>GNK<span class="token operator">-</span><span class="token number">5.0</span><span class="token punctuation">]</span>
remote<span class="token operator">:</span> Create a pull request <span class="token keyword">for</span> <span class="token string">'English'</span> on Gitee by visiting<span class="token operator">:</span>
remote<span class="token operator">:</span>     https<span class="token operator">:</span><span class="token comment">//gitee.com/HACV/test/pull/new/HACV:English...HACV:master</span>
To gitee<span class="token punctuation">.</span>com<span class="token operator">:</span>HACV<span class="token operator">/</span>test<span class="token punctuation">.</span>git
 <span class="token operator">*</span> <span class="token punctuation">[</span><span class="token keyword">new</span> branch<span class="token punctuation">]</span>      English <span class="token operator">-&gt;</span> English

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>English<span class="token punctuation">)</span>
$ ll
total <span class="token number">1</span>
<span class="token operator">-</span>rw<span class="token operator">-</span>r<span class="token operator">--</span>r<span class="token operator">--</span> <span class="token number">1</span> MaxWell <span class="token number">197121</span> <span class="token number">306</span> <span class="token number">5</span>月   <span class="token number">2</span> <span class="token number">08</span><span class="token operator">:</span><span class="token number">58</span> README<span class="token punctuation">.</span>md

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>English<span class="token punctuation">)</span>
$ git checkout master
Switched to branch <span class="token string">'master'</span>
Your branch is up to date with <span class="token string">'origin/master'</span><span class="token punctuation">.</span>

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ git pull
Already up to date<span class="token punctuation">.</span>

    
MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ ll
total <span class="token number">1</span>
drwxr<span class="token operator">-</span>xr<span class="token operator">-</span>x <span class="token number">1</span> MaxWell <span class="token number">197121</span>  <span class="token number">0</span> <span class="token number">5</span>月   <span class="token number">2</span> <span class="token number">09</span><span class="token operator">:</span><span class="token number">00</span> China<span class="token operator">/</span>
<span class="token operator">-</span>rw<span class="token operator">-</span>r<span class="token operator">--</span>r<span class="token operator">--</span> <span class="token number">1</span> MaxWell <span class="token number">197121</span> <span class="token number">30</span> <span class="token number">5</span>月   <span class="token number">2</span> <span class="token number">09</span><span class="token operator">:</span><span class="token number">00</span> README<span class="token punctuation">.</span>md

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ git checkout English
Switched to branch <span class="token string">'English'</span>

MaxWell@DESKTOP<span class="token operator">-</span><span class="token number">5</span>B8E7K2 MINGW64 <span class="token operator">~</span><span class="token operator">/</span>Desktop<span class="token operator">/</span><span class="token function">test</span> <span class="token punctuation">(</span>English<span class="token punctuation">)</span>
$ ll
total <span class="token number">1</span>
<span class="token operator">-</span>rw<span class="token operator">-</span>r<span class="token operator">--</span>r<span class="token operator">--</span> <span class="token number">1</span> MaxWell <span class="token number">197121</span> <span class="token number">306</span> <span class="token number">5</span>月   <span class="token number">2</span> <span class="token number">09</span><span class="token operator">:</span><span class="token number">01</span> README<span class="token punctuation">.</span>md

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br></div></div><h3 id="_4-2-如何删除远程某分支？"><a href="#_4-2-如何删除远程某分支？" class="header-anchor">#</a> 4.2.如何删除远程某分支？</h3> <blockquote><p><a href="https://chinese.freecodecamp.org/news/how-to-delete-a-git-branch-both-locally-and-remotely/" target="_blank" rel="noopener noreferrer">参考文档<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></blockquote> <p>此外，我观察到，这样删除分支，我们发现commit并没有变化。</p> <ul><li><p>当一个分支被推送并合并到远程分支后，<code>-d</code> 才会本地删除该分支。</p></li> <li><p>如果一个分支还没有被推送或者合并，那么可以使用<code>-D</code>强制删除它。</p></li> <li><p>使用这个命令可以远程删除分支：<code>git push &lt;remote&gt; --delete &lt;branch&gt;</code>。</p></li> <li><p>你也可以使用这行简短的命令来远程删除分支：<code>git push &lt;remote&gt; :&lt;branch&gt;</code>，比如：<code>git push origin :fix/authentication</code>。</p></li> <li><p>使用以下命令同步分支列表：</p></li> <li><p><code>-p</code> 的意思是“精简”。这样，你的分支列表里就不会显示已远程被删除的分支了。</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> fetch -p
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div></li></ul> <div class="language-txt line-numbers-mode"><pre class="language-text"><code>MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (master)
$ git branch -d English
error: The branch 'English' is not fully merged.
If you are sure you want to delete it, run 'git branch -D English'.

MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (master)
$ git branch -D English
Deleted branch English (was 6b8830c).

MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (master)
$ git branch
* master

MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (master)
$ git push origin -delete English
error: did you mean `--delete` (with two dashes ?)

MaxWell@DESKTOP-5B8E7K2 MINGW64 ~/Desktop/test (master)
$ git push origin --delete English
remote: Powered by GITEE.COM [GNK-5.0]
To gitee.com:HACV/test.git
 - [deleted]         English
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h3 id="_4-3-git中可以使用的linux命令『探秘』"><a href="#_4-3-git中可以使用的linux命令『探秘』" class="header-anchor">#</a> 4.3.Git中可以使用的linux命令『探秘』</h3> <ul><li><p>还有更多，或许是全部？？没有验证</p></li> <li><p>知乎上有人说Git中封装了小型的bash，而且，我们发现，它里面还能用<code>ssh</code></p></li> <li><p>git当下载器，借助Gitee食用更佳</p></li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git clone git@github.com:HACV/Temp.git</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_4-4-分支提交失败的情况"><a href="#_4-4-分支提交失败的情况" class="header-anchor">#</a> 4.4.分支提交失败的情况</h3> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git push origin master</span>
error: src refspec master does not match any.
error: failed to push some refs to <span class="token string">'git@github.com:HACV/Temp.git'</span>

//额，发现原来弄出来的分支，不叫master交main。。。
MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/Temp (main)
<span class="token command">$ git push origin main</span>
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 292 bytes | 292.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:HACV/Temp.git
   058f8bc..e197d47  main -&gt; main
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git branch dev</span>

MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/Temp (main)
<span class="token command">$ git branch</span>
  dev
* main

MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/Temp (main)
<span class="token command">$ git checkout dev</span>
Switched to branch <span class="token string">'dev'</span>

MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/Temp (dev)
<span class="token command">$ git branch</span>
* dev
  main
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>等价于一句</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git checkout<span class="token parameter"> -b</span> dev</span>
Switched to a new branch <span class="token string">'dev'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-git line-numbers-mode"><pre class="language-git"><code>当前是main分支

git merge dev
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><div class="language-git line-numbers-mode"><pre class="language-git"><code>合并完成后，就可以放心地删除dev分支了：

<span class="token command">$ git branch<span class="token parameter"> -d</span> dev</span>
Deleted branch dev (was b17d20e).
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><h3 id="_4-5-git-add和git-commit的对比"><a href="#_4-5-git-add和git-commit的对比" class="header-anchor">#</a> 4.5.<code>git add</code>和<code>git commit</code>的对比</h3> <p><img src="https://cdn.jsdelivr.net/gh/HACV/picture/img/20211108094203.png" alt="git3"></p> <p>Q: add和commit的区别，是不是多次一举？？</p> <ul><li><p>使用 git add 命令将想要快照的内容写入<strong>缓存区</strong>，</p></li> <li><p>使用 git commit命令则将缓存区内容添加到**仓库（这里说的本地仓库）**中</p></li> <li><p><a href="https://blog.csdn.net/PS_Xie/article/details/87978006" target="_blank" rel="noopener noreferrer">链接<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p></li> <li><p>修改文件</p></li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git status</span>
On branch master
nothing to commit, working tree clean

MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/learn (master)
<span class="token command">$ git status</span>
On branch master
Changes not staged for commit:
  (use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to update what will be committed)
  (use <span class="token string">&quot;git checkout -- &lt;file&gt;...&quot;</span> to discard changes in working directory)

        modified:   readme.txt

no changes added to commit (use <span class="token string">&quot;git add&quot;</span> and/or <span class="token string">&quot;git commit -a&quot;</span>)
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><p>我这个时候，没有将它add到staged中去，更加不可能commit</p> <p>git diff 看看具体修改了什么内容</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git diff readme.txt</span>
diff --git a/readme.txt b/readme.txt
index e69de29..9551247 100644
<span class="token deleted">--- a/readme.txt</span>
<span class="token inserted">+++ b/readme.txt</span>
<span class="token coord">@@ -0,0 +1 @@</span>
<span class="token inserted">+2123</span>
\ No newline at end of file
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>知道了对readme.txt作了什么修改后，再把它提交到仓库就放心多了，<strong>提交修改和提交新文件是一样的两步</strong></p> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git status</span>
On branch master
Changes to be committed:
  (use <span class="token string">&quot;git reset HEAD &lt;file&gt;...&quot;</span> to unstage)

        modified:   readme.txt
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>工作目录是干净（working tree clean）</p> <h3 id="_4-6-版本回退—回到过去"><a href="#_4-6-版本回退—回到过去" class="header-anchor">#</a> 4.6.版本回退—回到过去</h3> <div class="language-git line-numbers-mode"><pre class="language-git"><code>$ cat readme.txt
2123
2222
MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/learn (master)
<span class="token command">$ git reset<span class="token parameter"> --hard</span> HEAD^</span>
HEAD is now at 2e4da7b 第2次提交

MaxWell@DESKTOP-5B8E7K2 MINGW64 /C/Users/MaxWell/Desktop/learn (master)
$ cat readme.txt
2123
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><ul><li>版本前进—回到当前的未来</li></ul> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token command">$ git reset<span class="token parameter"> --hard</span> a68dea			//其实这里是不全的，就算不打全也是可以的</span>
HEAD is now at a68dea8 di 3 ci
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><div class="language-git line-numbers-mode"><pre class="language-git"><code>git reflog查看命令历史
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_4-7-神奇的git-reset"><a href="#_4-7-神奇的git-reset" class="header-anchor">#</a> 4.7.神奇的<code>git reset</code></h3> <ul><li><code>git reset</code>命令既可以回退版本，也可以把暂存区的修改回退到工作区。</li> <li>当我们用HEAD时，表示最新的版本。</li></ul> <h3 id="_4-8-git-checkout"><a href="#_4-8-git-checkout" class="header-anchor">#</a> 4.8.<code>git checkout --</code></h3> <ul><li><p>file命令中的<code>--</code>很重要，没有<code>--</code>，就变成了“切换到另一个分支”的命令</p> <ul><li>我们在后面的分支管理中会再次遇到git checkout命令</li></ul></li> <li><p>命令<code>git checkout -- readme.txt</code>意思就是，把readme.txt文件在工作区的修改全部撤销，这里有两种情况：</p> <ul><li>一种是readme.txt自修改后还没有被放到暂存区，现在，撤销修改就回到和版本库一模一样的状态；</li></ul></li></ul> <h3 id="_4-9-git-从远程服务器更新本地项目"><a href="#_4-9-git-从远程服务器更新本地项目" class="header-anchor">#</a> 4.9.git 从远程服务器更新本地项目</h3> <ul><li>参考<a href="https://blog.csdn.net/hanqingsong412/article/details/50466622" target="_blank" rel="noopener noreferrer">链接<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>记得对比<code>git pull</code>和<code>git fetch</code></li></ul> <h2 id="_5-github强化"><a href="#_5-github强化" class="header-anchor">#</a> 5.GitHub强化</h2> <h3 id="_5-1-github搜索强化"><a href="#_5-1-github搜索强化" class="header-anchor">#</a> 5.1.GitHub搜索强化</h3> <p>github上查找star数目大于69.5k的的方法</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code>stars:&gt;69500
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="_5-2-忽略管理的一个“坑”"><a href="#_5-2-忽略管理的一个“坑”" class="header-anchor">#</a> 5.2.忽略管理的一个“坑”</h3> <ul><li>gitignore生效</li></ul> <p><code>gitignore</code>生效的前提好像是</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token comment">#.gitignore</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>这句话要加在这个文件的最前面</p> <p>比如</p> <div class="language-git line-numbers-mode"><pre class="language-git"><code><span class="token comment">#.gitignore</span>
_book
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h2 id="⭐️工程实践总结"><a href="#⭐️工程实践总结" class="header-anchor">#</a> ⭐️工程实践总结</h2> <h3 id="_1-写完代码要提交-提交pr"><a href="#_1-写完代码要提交-提交pr" class="header-anchor">#</a> 1.写完代码要提交+提交PR</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code><span class="token function">git</span> checkout -b new		<span class="token comment">#新建分支，并且切换分支</span>
<span class="token function">ls</span>
<span class="token function">git</span> <span class="token function">add</span> modify_file.name
<span class="token function">git</span> commit -m <span class="token string">&quot;new branch2021&quot;</span>	
<span class="token function">git</span> <span class="token function">diff</span> master new	<span class="token comment">#比较一下代码，在提交前记得检测「不要引发上线事故」</span>
<span class="token function">git</span> push origin new	<span class="token comment">#将本地new分支提交到远程Gitee（也就是Origin）</span>
<span class="token comment"># 后续自行在你的GitHub/GitLab提交你的描述+PR请求</span>
----------------------------------------------------
<span class="token function">git</span> checkout master	<span class="token comment">#切换当前分支为master</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="_2-提交的分支错误-删除本地分支和远程分支"><a href="#_2-提交的分支错误-删除本地分支和远程分支" class="header-anchor">#</a> 2.提交的分支错误-删除本地分支和远程分支</h3> <ul><li>3板斧</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>whoway@LAPTOP-OS MINGW64 ~/Desktop/os <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ <span class="token function">git</span> branch -d new					<span class="token comment">#// delete branch locally</span>
error: The branch <span class="token string">'new'</span> is not fully merged.
If you are sure you want to delete it, run <span class="token string">'git branch -D new'</span><span class="token builtin class-name">.</span>

whoway@LAPTOP-OS MINGW64 ~/Desktop/os <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ <span class="token function">git</span> branch -D new
Deleted branch new <span class="token punctuation">(</span>was c18a3d2<span class="token punctuation">)</span>.

whoway@LAPTOP-OS MINGW64 ~/Desktop/os <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ <span class="token function">git</span> push origin master
Everything up-to-date

whoway@LAPTOP-OS MINGW64 ~/Desktop/os <span class="token punctuation">(</span>master<span class="token punctuation">)</span>
$ <span class="token function">git</span> push origin --delete new					<span class="token comment">#delete branch remotely</span>
remote: Powered by GITEE.COM <span class="token punctuation">[</span>GNK-6.2<span class="token punctuation">]</span>
To gitee.com:HACV/os.git
 - <span class="token punctuation">[</span>deleted<span class="token punctuation">]</span>         new

</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br></div></div><h3 id="_3-代码走查「自行比较自己的分支」"><a href="#_3-代码走查「自行比较自己的分支」" class="header-anchor">#</a> 3.代码走查「自行比较自己的分支」</h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>git查看当前分支所属
<span class="token function">git</span> branch --v		<span class="token comment">#查看当前啥分支	等价于	git branch -vv		#查看当前啥分支</span>
<span class="token function">git</span> config --lis	<span class="token comment">#查看分支属于谁，用户名+邮箱名</span>

<span class="token function">git</span> <span class="token function">diff</span> branch1 branch2 --stat   		//显示出所有有差异的文件列表

<span class="token function">git</span> <span class="token function">diff</span> branch1 branch2 文件名<span class="token punctuation">(</span>带路径<span class="token punctuation">)</span>   	//显示指定文件的详细差异

<span class="token function">git</span> <span class="token function">diff</span> branch1 branch2                   //显示出所有有差异的文件的详细差异
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h4 id="_3-1-git查看「某分支」相较master的改动"><a href="#_3-1-git查看「某分支」相较master的改动" class="header-anchor">#</a> 3.1.git查看「某分支」相较master的改动</h4> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>Git 查看某次commit的内容

知道commit id的情况下:
<span class="token number">1</span>. 获取commit <span class="token function">id</span>
	<span class="token function">git</span> log 

<span class="token number">2</span>. 查看commit内容
	<span class="token function">git</span> show commit_id
	<span class="token function">git</span> show ctz <span class="token operator">&gt;</span> modify.patch
	
查看最近n次提交的修改
   <span class="token function">git</span> log -p -n
指定n为1则可以查看最近一次修改的内容
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><h3 id="_4-git撤销对某个文件的修改"><a href="#_4-git撤销对某个文件的修改" class="header-anchor">#</a> 4.git撤销对某个文件的修改</h3> <ul><li><p>1、如果没有被git add到索引区</p> <ul><li><code>git checkout build.sh</code> 便可撤销对文件build.sh的修改</li> <li>注意：<code>git checkout</code> // 放弃所有文件的所有修改</li></ul></li> <li><p>2、git 恢复某个文件到指定版本</p> <ul><li>git提交了比较多的文件到远程，但是在合并时发现其中有一个文件合并有冲突或者某个原因不想修改该文件了，那就需要单独把这个文件回退到上一个提交版本状态。方法如下：</li> <li>1.首先查看一下该文件的commit记录：<code>git log 文件名</code>，例如 <code>git log src/index.java</code></li> <li>2.找到需要提交到上一个版本的commit号，然后checkout该文件的上一版本，输入下面的指令：
<ul><li><code>git checkout [commit id]</code> 文件，例如 <code>git checkout a57fb4b474888f0db4cba18de2180496 src/index.java</code></li></ul></li></ul></li></ul> <h3 id="_5-公司给了新的分支-拉去"><a href="#_5-公司给了新的分支-拉去" class="header-anchor">#</a> 5.公司给了新的分支-拉去</h3> <blockquote><p>git拉取远程分支并创建本地分支</p></blockquote> <p>拉取远程分支并创建本地分支</p> <ul><li>方法一
使用如下命令：</li></ul> <p><code>git checkout -b 本地分支名x origin/远程分支名x</code>
使用该方式会在本地新建分支x，并自动切换到该本地分支x。</p> <p>采用此种方法建立的本地分支会和远程分支<strong>建立映射关系</strong>。</p> <ul><li>方式二
使用如下命令：</li></ul> <p><code>git fetch origin 远程分支名x:本地分支名x</code>
使用该方式会在本地新建分支x，但是不会自动切换到该本地分支x，需要手动checkout。</p> <p>采用此种方法建立的本地分支<strong>不会</strong>和远程分支建立映射关系。</p> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>whowoay@XXXX:~/gcc-$ <span class="token function">git</span> branch -r
  origin/HEAD -<span class="token operator">&gt;</span> origin/master
  origin/ctz
  origin/dev-opt
  origin/lhupeephole2
  origin/master
whowoay@XXXX:~/gcc-$ <span class="token function">git</span> checkout -b dev-opt orgin/dev-opt
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><h3 id="_6-如何用git命令生成patch和打patch"><a href="#_6-如何用git命令生成patch和打patch" class="header-anchor">#</a> 6.如何用git命令生成Patch和打Patch</h3> <ul><li>参考资料：https://blog.csdn.net/qq_15936309/article/details/90521360</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>$ <span class="token function">git</span> apply --stat aaaa.patch   　　　　  <span class="token comment"># 查看patch的情况</span>

$ <span class="token function">git</span> apply --check aaaa.patch   　　　  <span class="token comment"># 检查patch是否能够打上，如果没有任何输出，则说明无冲突，可以打上</span>

<span class="token punctuation">(</span>注：git apply是另外一种打patch的命令，其与git am的区别是，git apply并不会将commit message等打上去，打完patch后需要重新git add和git commit，而git am会直接将patch的所有信息打上去，而且不用重新git add和git commit,author也是patch的author而不是打patch的人<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>具体表现如下：</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>whoway@dell:~/open_source/gcc-9.1.0/libgcc$ <span class="token function">git</span> status
On branch dev-opt
Your branch is up to <span class="token function">date</span> with <span class="token string">'origin/dev-opt'</span><span class="token builtin class-name">.</span>

Untracked files:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to include <span class="token keyword">in</span> what will be committed<span class="token punctuation">)</span>
        a.patch
        tempwhoway

nothing added to commit but untracked files present <span class="token punctuation">(</span>use <span class="token string">&quot;git add&quot;</span> to track<span class="token punctuation">)</span>

whoway@dell:~/open_source/gcc-9.1.0/libgcc$ <span class="token function">git</span> apply --check a.patch

whoway@dell:~/open_source/gcc-9.1.0/libgcc$ <span class="token function">git</span> apply a.patch

whoway@dell:~/open_source/gcc-9.1.0/libgcc$ <span class="token function">git</span> status
On branch dev-opt
Your branch is up to <span class="token function">date</span> with <span class="token string">'origin/dev-opt'</span><span class="token builtin class-name">.</span>

Changes not staged <span class="token keyword">for</span> commit:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to update what will be committed<span class="token punctuation">)</span>
  <span class="token punctuation">(</span>use <span class="token string">&quot;git restore &lt;file&gt;...&quot;</span> to discard changes <span class="token keyword">in</span> working directory<span class="token punctuation">)</span>
        modified:   libgcc2.c

Untracked files:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to include <span class="token keyword">in</span> what will be committed<span class="token punctuation">)</span>
        a.patch
        tempwhoway

no changes added to commit <span class="token punctuation">(</span>use <span class="token string">&quot;git add&quot;</span> and/or <span class="token string">&quot;git commit -a&quot;</span><span class="token punctuation">)</span>


whoway@dell:~/open_source/gcc-9.1.0/libgcc$ <span class="token function">git</span> apply --stat a.patch
 libgcc/libgcc2.c <span class="token operator">|</span>   <span class="token number">28</span> ++++++++++++++++++++++++++++
 <span class="token number">1</span> <span class="token function">file</span> changed, <span class="token number">28</span> insertions<span class="token punctuation">(</span>+<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br></div></div><h3 id="_7-git-cherry-pick进行commit的pick"><a href="#_7-git-cherry-pick进行commit的pick" class="header-anchor">#</a> 7.<code>git cherry-pick</code>进行commit的pick</h3> <ul><li>参考链接：https://blog.csdn.net/u010697394/article/details/60956514</li></ul> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>whoway@dell:~/open_source/gcc-9.1.0$ <span class="token function">git</span> log
commit f8a7cf <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> ctz, origin/ctz<span class="token punctuation">)</span>
Author: whoway <span class="token operator">&lt;</span>hacvhacv@qq.com<span class="token operator">&gt;</span>
Date:   Sat Dec <span class="token number">4</span> <span class="token number">11</span>:58:18 <span class="token number">2021</span> +0800

    modify_ctzsi2_ctzdi2_realize

commit 4e24b2 <span class="token punctuation">(</span>origin/master, origin/HEAD, master<span class="token punctuation">)</span>
Merge: 9eb72b764 32703ac7f
Author: xinxin <span class="token operator">&lt;</span>xinxin.ding@xin-dev.com<span class="token operator">&gt;</span>
Date:   Sat Nov <span class="token number">6</span> 09:15:20 <span class="token number">2021</span> +0800

    Merge branch <span class="token string">'master'</span> into <span class="token string">'master'</span>
    
    Master
    
    See merge request code-opt/gcc-9.1.0<span class="token operator">!</span><span class="token number">1</span>


whoway@XXXX:~/open_source/gcc-9.1.0$ <span class="token function">git</span> checkout dev-opt 
Switched to branch <span class="token string">'dev-opt'</span>
Your branch is up to <span class="token function">date</span> with <span class="token string">'origin/dev-opt'</span><span class="token builtin class-name">.</span>

whoway@dell:~/open_source/gcc-9.1.0$ <span class="token function">git</span> cherry-pick f8a7cf
<span class="token punctuation">[</span>dev-opt 1e2600715<span class="token punctuation">]</span> modify_ctzsi2_ctzdi2_realize
 Date: Sat Dec <span class="token number">4</span> <span class="token number">11</span>:58:18 <span class="token number">2021</span> +0800
 <span class="token number">1</span> <span class="token function">file</span> changed, <span class="token number">22</span> insertions<span class="token punctuation">(</span>+<span class="token punctuation">)</span>, <span class="token number">2</span> deletions<span class="token punctuation">(</span>-<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br></div></div><h3 id="_8-从commit到stage到修改到取消修改-回退-git-reset-xx-soft"><a href="#_8-从commit到stage到修改到取消修改-回退-git-reset-xx-soft" class="header-anchor">#</a> 8.从commit到stage到修改到取消修改(回退)<code>git --reset XX --soft</code></h3> <div class="language-bash line-numbers-mode"><pre class="language-bash"><code>whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">ls</span>
dg.exp  16bits.c  8bits.c


whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> log
commit 720e55e56335975d7729816a542f7f5af0b2d7f1 <span class="token punctuation">(</span>HEAD -<span class="token operator">&gt;</span> lbpeephole2<span class="token punctuation">)</span>
Author: whoway <span class="token operator">&lt;</span>hacvhacv@qq.com<span class="token operator">&gt;</span>
Date:   Tue Dec <span class="token number">7</span> <span class="token number">17</span>:29:18 <span class="token number">2021</span> +0800

    add_option_mlbu-lhu-opt_lhupeephole2

commit 1e2600715f0ae46a329f0b75866f529f299aa543 <span class="token punctuation">(</span>dev-opt<span class="token punctuation">)</span>
Author: whoway <span class="token operator">&lt;</span>hacvhacv@qq.com<span class="token operator">&gt;</span>
Date:   Sat Dec <span class="token number">4</span> <span class="token number">11</span>:58:18 <span class="token number">2021</span> +0800

    modify_si2_di2_realize

commit a3f117296f1a6ea77c9f44a343eded7ff79eb5f2 <span class="token punctuation">(</span>origin/dev-opt<span class="token punctuation">)</span>
Author: xinxinxin <span class="token operator">&lt;</span>xinxin@xin-dev.com<span class="token operator">&gt;</span>
Date:   Tue Dec <span class="token number">7</span> <span class="token number">16</span>:42:34 <span class="token number">2021</span> +0800

    dev-opt




whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> reset --soft a3f117296f1


whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> status
On branch lbpeephole2
Changes to be committed:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git restore --staged &lt;file&gt;...&quot;</span> to unstage<span class="token punctuation">)</span>
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/config/riscv/peephole.md
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/config/riscv/riscv.opt
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/libgcc2.c

Untracked files:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to include <span class="token keyword">in</span> what will be committed<span class="token punctuation">)</span>
        lbu2lhu16bits.c
        lbu2lhu8bits.c
        <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/tempwhoway


whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> restore --staged <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/libgcc2.c


whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> status
On branch lbpeephole2
Changes to be committed:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git restore --staged &lt;file&gt;...&quot;</span> to unstage<span class="token punctuation">)</span>
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/config/riscv/peephole.md
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/config/riscv/riscv.opt

Changes not staged <span class="token keyword">for</span> commit:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to update what will be committed<span class="token punctuation">)</span>
  <span class="token punctuation">(</span>use <span class="token string">&quot;git restore &lt;file&gt;...&quot;</span> to discard changes <span class="token keyword">in</span> working directory<span class="token punctuation">)</span>
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/libgcc2.c

Untracked files:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to include <span class="token keyword">in</span> what will be committed<span class="token punctuation">)</span>
        lbu2lhu16bits.c
        lbu2lhu8bits.c
        <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/tempwhoway



whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> restore <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/libgcc2.c


whoway@XXXX:~/open_source/gcc-9.1.0/gcc/testsuite/gcc.dg/codesize/execute$ <span class="token function">git</span> status
On branch lbu2lhupeephole2
Changes to be committed:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git restore --staged &lt;file&gt;...&quot;</span> to unstage<span class="token punctuation">)</span>
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/config/riscv/peephole.md
        modified:   <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/config/riscv/riscv.opt

Untracked files:
  <span class="token punctuation">(</span>use <span class="token string">&quot;git add &lt;file&gt;...&quot;</span> to include <span class="token keyword">in</span> what will be committed<span class="token punctuation">)</span>
        lbu2lhu16bits.c
        lbu2lhu8bits.c
        <span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/<span class="token punctuation">..</span>/libgcc/tempwhoway
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br><span class="line-number">41</span><br><span class="line-number">42</span><br><span class="line-number">43</span><br><span class="line-number">44</span><br><span class="line-number">45</span><br><span class="line-number">46</span><br><span class="line-number">47</span><br><span class="line-number">48</span><br><span class="line-number">49</span><br><span class="line-number">50</span><br><span class="line-number">51</span><br><span class="line-number">52</span><br><span class="line-number">53</span><br><span class="line-number">54</span><br><span class="line-number">55</span><br><span class="line-number">56</span><br><span class="line-number">57</span><br><span class="line-number">58</span><br><span class="line-number">59</span><br><span class="line-number">60</span><br><span class="line-number">61</span><br><span class="line-number">62</span><br><span class="line-number">63</span><br><span class="line-number">64</span><br><span class="line-number">65</span><br><span class="line-number">66</span><br><span class="line-number">67</span><br><span class="line-number">68</span><br><span class="line-number">69</span><br><span class="line-number">70</span><br><span class="line-number">71</span><br><span class="line-number">72</span><br><span class="line-number">73</span><br><span class="line-number">74</span><br><span class="line-number">75</span><br><span class="line-number">76</span><br><span class="line-number">77</span><br><span class="line-number">78</span><br><span class="line-number">79</span><br><span class="line-number">80</span><br><span class="line-number">81</span><br><span class="line-number">82</span><br></div></div><h3 id="_9-如果公司外网域名宕掉-git远程仓库地址变更本地如何修改"><a href="#_9-如果公司外网域名宕掉-git远程仓库地址变更本地如何修改" class="header-anchor">#</a> 9.如果公司外网域名宕掉-git远程仓库地址变更本地如何修改</h3> <ul><li><p>参考链接：https://blog.csdn.net/asdfsfsdgdfgh/article/details/54981823</p></li> <li><p>gcc -D选项 编译时添加宏定义</p></li> <li><p>https://blog.csdn.net/y396397735/article/details/53736416?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0.fixedcolumn&amp;spm=1001.2101.3001.4242.1</p></li> <li><p>git撤销commit 并保存之前的修改</p></li> <li><p>https://blog.csdn.net/mentalitys/article/details/81079761</p></li></ul> <h2 id="🍀参考资料"><a href="#🍀参考资料" class="header-anchor">#</a> 🍀参考资料</h2> <ul><li>GitHub官方<a href="https://docs.github.com/cn/github/searching-for-information-on-github/searching-for-repositories" target="_blank" rel="noopener noreferrer">中文文档<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>忽略『<a href="https://www.liaoxuefeng.com/wiki/896043488029600/900004590234208" target="_blank" rel="noopener noreferrer">特殊文件<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a>』</li> <li>官方<a href="https://git-scm.com/docs/gitignore" target="_blank" rel="noopener noreferrer">忽略<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>Git大文件存储，<a href="https://git-lfs.github.com/" target="_blank" rel="noopener noreferrer">官方<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>Linux<a href="https://linuxtools-rst.readthedocs.io/zh_CN/latest/#" target="_blank" rel="noopener noreferrer">快速教程<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li> <li>Gitlab官方文档<a href="https://docs.gitlab.com/" target="_blank" rel="noopener noreferrer">https://docs.gitlab.com/<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div> <div class="page-edit"><!----> <!----></div> <!----> </div> <!----></div></div>
    <script src="/assets/js/app.c70e21ad.js" defer></script><script src="/assets/js/99.54c8207b.js" defer></script>
  </body>
</html>
